import GamePlatformConfig from "./GamePlatformConfig";
import { GamePlatformType } from "./GamePlatformType";
import SDK from "./SDK/SDK";
import WXSDK from "./SDK/WXSDK";
import PCSDK from "./SDK/PCSDK";
import HeyGameOPPOSDK from "./SDK/HeyGameOPPOSDK";


export default class GamePlatform {

    private static _config: GamePlatformConfig = null;
    public static get Config(): GamePlatformConfig {
        return this._config;
    }

    private static _sdk: SDK = null;
    public static get SDK(): SDK {
        return this._sdk;
    }

    public static init(param: GamePlatformConfig) {
        console.log(param);
        this._config = param;
        switch (param.type) {
            case GamePlatformType.PC: {
                this._sdk = new PCSDK();
                break;
            }
            case GamePlatformType.WX: {
                this._sdk = new WXSDK();
                break;
            }
            case GamePlatformType.HeyGameOPPO: {
                this._sdk = new HeyGameOPPOSDK();
                break;
            }
            case GamePlatformType.HeyGameVIVO: {
                this._sdk = new HeyGameOPPOSDK();
                break;
            }
            default: {
                this._sdk = new PCSDK();
                break;
            }
        }

        this._sdk.config = this._config;
        this._sdk.init(this._config);
        this._sdk.onEvents();
        this._sdk.loadRecord();
    }

}
